<?php
/*
 * Created on 2011-1-15
 * by lixilei
 */

class MessageBiz{
	
	/**
	 * 记录发布的消息
	 */
	public function recordMessage($user_id, $shop_id, $shop_statics_id, $message, $weightJSON, $publishResult){
		$messageDB = spClass("MessageModel", null, MODEL_PATH."MessageModel.php");
		while(TRUE){
			$message_id  = time()*1000000 + rand(1, 999999);
			$result = $messageDB->find(array("message_id"=>$message_id));
			if($result == FALSE){
				break;
			}
		}
		$row = array(
			"message_id" => $message_id,
			"user_id" => $user_id,
			"shop_id" => $shop_id,
			"message" => $message,
			"shop_statics_id" => $shop_statics_id,
			"weight_json" => $weightJSON,
			"publish_result" => $publishResult,
		);
		$result = $messageDB->create($row);
		if($result != FALSE){
			return $result;
		}
		return 0;
	}
}
?>
